"""
@Time    : 2025/7/22 14:57
@Author  : white.tie
@File    : 高级依赖项.py
@Desc    : 
"""
import uvicorn
from fastapi import FastAPI, Depends

app = FastAPI()


class FixedContentQueryChecker:
    def __init__(self, fixed_content: str):
        self.fixed_content = fixed_content

    def __call__(self, q: str = ""):
        if q:
            return self.fixed_content in q
        return False

checker = FixedContentQueryChecker("bar")
@app.get("/query-checker/")
async def read_query_check(fixed_content_included: bool = Depends(checker)):
    return {"fixed_content_included": fixed_content_included}

if __name__ == '__main__':
    uvicorn.run(app)
